let funcList = [
    {
        name: 'datetime',
        title: '日期时间',
        onclick: () => {
            log(datetime());
        }
    }, {
        name: 'randomIndex',
        title: '随机索引',
        onclick: () => {
            log(randomIndex(10));
        }
    }, {
        name: 'j2s',
        title: 'Json to String',
        onclick: () => {
            log(j2s({name: 'wang', age: 18}));
        }
    }, {
        name: 's2j',
        title: 'String to Json',
        onclick: () => {
            log(s2j('{"name":"wang","age":18}'));
        }
    }, {
        name: 'getDocDimension',
        title: '获取文档尺寸',
        onclick: () => {
            log(getDocDimension());
        }
    }, {
        name: 'humanSize',
        title: '人类可读的大小',
        onclick: () => {
            for (let i = 0; i < 10; i++) {
                let bytes = Math.pow(1024, i);
                log(bytes + ' bytes => ' + humanSize(bytes));
            }
        }
    }, {
        name: 'humanTime',
        title: '人类可读的时间',
        onclick: () => {
            let arr = [1, 60, 60 * 60, 60 * 60 * 24, 60 * 60 * 24 + 60 * 60 * 12];
            for (let i = 0; i < arr.length; i++) {
                let ms = arr[i] * 1e3;
                log(ms + ' ms => ' + humanTime(ms));
            }
        }
    }
];

documentReady(() => {
    let funcBox = document.getElementById('funcBox');
    for (let func of funcList) {
        var p = dce('p');
        p.textContent = func.name;
        p.title = func.title;
        p.onclick = func.onclick;
        funcBox.appendChild(p);
    }
});
